package com.team.arms.public_data.mapper;
import com.baomidou.mybatisplus.core.injector.methods.SelectList;
import com.team.arms.public_data.domain.VisitSurveyConfiguration;
import com.team.arms.public_data.domain.dto.TroopInfoDto;
import com.team.arms.public_data.domain.vo.TroopInfoVo;
import org.apache.ibatis.annotations.Param;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.team.arms.public_data.domain.TroopInfo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Entity com.ruoyi.yuding.domain.TroopInfo
 */
public interface TroopInfoMapper extends BaseMapper<TroopInfo> {

    int insertAll(TroopInfo troopInfo);

    @Select("<script>SELECT y.troop_info_id,y.troop_name,s.soldier_info_name,y.year,y.batch,y.number_people,l.lottery_sort_value,y.nearby,\n" +
            " y.condition_solidier,y.surplus_number_people,y.complete_number,y.early_batch,y.volunteer_number,y.volunteer_one_number,y.volunteer_two_number,\n" +
            " y.is_exclude,y.non_college_student_number,y.already_non_college_student_number\n" +
            "from y_troop_info AS y,g_soldier_information AS s , y_lottery_table AS l\n"+
            "where y.soldier_info_id=s.soldier_info_id and y.lottery_number = l.lottery_number\n" +
            "<if test=\"troopName != null and troopName != ''\">\n" +
            "        and y.troop_name like CONCAT('%',#{troopName},'%')\n" +
            " </if><if test=\"soldierInfoName != null and soldierInfoName != ''\">\n" +
            "     and s.soldier_info_name like CONCAT('%',#{soldierInfoName},'%')\n" +
            " </if><if test=\"year != null and year != ''\">\n" +
            "     and y.year like CONCAT('%',#{year},'%')\n" +
            " </if><if test=\"batch != null and batch != ''\">" +
            "     and y.batch = #{batch}\n" +
            "</if><if test=\"numberPeople != null and numberPeople != ''\">" +
            "        and y.number_people like CONCAT('%',#{numberPeople},'%')\n" +
            "</if><if test=\"nearby != null and nearby != ''\">" +
            "        and y.nearby = #{nearby}\n" +
            "</if><if test=\"conditionSolidier != null and conditionSolidier != ''\">" +
            "        and y.condition_solidier = #{conditionSolidier}\n" +
            "</if><if test=\"surplusNumberPeople != null and surplusNumberPeople != ''\">" +
            "        and y.surplus_number_people = #{surplusNumberPeople}\n" +
            "</if><if test=\"completeNumber != null and completeNumber != ''\">" +
            "        and y.complete_number = #{completeNumber}\n" +
            "</if><if test=\"earlyBatch != null and earlyBatch != ''\">" +
            "        and y.early_batch = #{earlyBatch}\n" +
            "</if><if test=\"volunteerNumber != null and volunteerNumber != ''\">" +
            "        and y.volunteer_number = #{volunteerNumber}\n" +
            "</if><if test=\"lotterySortValue != null and lotterySortValue != ''\">" +
            "        and l.lottery_sort_value like CONCAT('%',#{lotterySortValue},'%')\n" +
            "</if><if test=\"volunteerOneNumber != null and volunteerOneNumber != ''\">" +
            "        and y.volunteer_one_number = #{volunteerOneNumber}\n" +
            "</if><if test=\"volunteerTwoNumber != null and volunteerTwoNumber != ''\">" +
            "        and y.volunteer_two_number = #{volunteerTwoNumber}\n" +
            "</if><if test=\"isExclude != null and isExclude != ''\">" +
            "        and y.is_exclude = #{isExclude}\n" +
            "</if><if test=\"nonCollegeStudentNumber != null and nonCollegeStudentNumber != ''\">" +
            "        and y.non_college_student_number = #{nonCollegeStudentNumber}\n" +
            "</if><if test=\"alreadyNonCollegeStudentNumber != null and alreadyNonCollegeStudentNumber != ''\">" +
            "        and y.already_non_college_student_number = #{alreadyNonCollegeStudentNumber}\n" +
            "</if></script>")
    List<TroopInfoVo> selectListTroopInfo(TroopInfoDto troopInfoDto);

    @Select("SELECT y.troop_info_id,y.troop_name,s.soldier_info_name,y.year,y.batch,y.number_people,l.lottery_sort_value,y.nearby,\n" +
            " y.condition_solidier,y.surplus_number_people,y.complete_number,y.early_batch,y.volunteer_number,y.volunteer_one_number,y.volunteer_two_number,\n" +
            " y.is_exclude,y.non_college_student_number,y.already_non_college_student_number \n" +
            "from y_troop_info AS y,g_soldier_information AS s , y_lottery_table AS l \n" +
            "where y.soldier_info_id=s.soldier_info_id and y.lottery_number = l.lottery_number\n" +
            "and ${field} like \"%${content}%\"")
    List<TroopInfoVo> selectByFiled(@Param("field") String field, @Param("content") String content);

    @Select("SELECT y.troop_info_id,y.troop_name,s.soldier_info_name,y.year,y.batch,y.number_people,l.lottery_sort_value,y.nearby,\n" +
            " y.condition_solidier,y.surplus_number_people,y.complete_number,y.early_batch,y.volunteer_number,y.volunteer_one_number,y.volunteer_two_number,\n" +
            " y.is_exclude,y.non_college_student_number,y.already_non_college_student_number \n" +
            "from y_troop_info AS y,g_soldier_information AS s , y_lottery_table AS l \n" +
            "where y.soldier_info_id=s.soldier_info_id and y.lottery_number = l.lottery_number")
    List<TroopInfoVo> selectList();

    @Select("SELECT y.troop_info_id,y.troop_name,s.soldier_info_name,y.year,y.batch,y.number_people,l.lottery_sort_value,y.nearby,\n" +
            " y.condition_solidier,y.surplus_number_people,y.complete_number,y.early_batch,y.volunteer_number,y.volunteer_one_number,y.volunteer_two_number,\n" +
            " y.is_exclude,y.non_college_student_number,y.already_non_college_student_number\n" +
            "from y_troop_info AS y,g_soldier_information AS s , y_lottery_table AS l\n" +
            "where y.soldier_info_id=s.soldier_info_id and y.lottery_number = l.lottery_number\n" +
            "and y.troop_info_id = #{troopInfoId}")
    TroopInfoVo selectAllByTroopInfoId(@Param("troopInfoId") String troopInfoId);
}




